<%@ page pageEncoding="UTF-8"%>
<div id="add_user_win" class="easyui-dialog"
	style="width: 440px; height: 210px; padding: 10px 20px" closed="true"
	buttons="#dlg-buttons">
	<form id="add_user_form" method="post" novalidate>
		<table>
			<tr>
				<td height="25">
					<label>
						用 户 名:
					</label>
				</td>
				<td>
					<input id="loginName" name="user.loginName" class="easyui-validatebox"
						data-options="required:true,validType:'length[3,10]'"
						style="width: 300px">
				</td>
			</tr>
			<tr>
				<td height="25">
					<label>
						年&nbsp;&nbsp;&nbsp;&nbsp;龄:
					</label>
				</td>
				<td>
					<input id="age" name="user.age" class="easyui-validatebox"
						data-options="required:true" style="width: 300px">
				</td>
			</tr>
			<tr>
				<td height="25">
					<label>
						性&nbsp;&nbsp;&nbsp;&nbsp;别:
					</label>
				</td>
				<td>
					<input id="sex" name="user.sex" class="easyui-validatebox"
						data-options="required:true" style="width: 300px">
				</td>
			</tr>
			<tr>
				<td height="25">
					<label>
						联系地址:
					</label>
				</td>
				<td>
					<input id="address" name="user.address" style="width: 300px">
				</td>
			</tr>
		</table>
	</form>
</div>

<div id="dlg-buttons">
	<a href="javascript:void(0)" class="easyui-linkbutton"
		iconCls="icon-ok" id="save" >保存</a>
	<a href="javascript:void(0)" class="easyui-linkbutton"
		iconCls="icon-cancel"
		onclick="javascript:$('#add_user_win').dialog('close')">取消</a>
</div>

<script type="text/javascript"><%--
        function saveUser(){  
           $('#add_user_form').form('submit',{  
               url: url,  
               onSubmit: function(){  
                   return $(this).form('validate');  
               },  
               success: function(result){  
                   var result = eval('('+result+')');  
                   alert(result);
                   if (result.errorMsg){  
                       $.messager.show({  
                           title: 'Error',  
                           msg: result.errorMsg  
                       });  
                   } else {  
                       $('#add_user_win').dialog('close');      
                       $('#dg').datagrid('reload');    
                   }  
               }  
           });  
       }  --%>
       
       $('#save').click(function (){
    		  $('#add_user_form').form('submit', {
    		  	 url: url,
    		     success:function(data){
    		          var a = eval('(' + data + ')');
    		          $.messager.alert('增加用户', a.message, 'info');
	    		      if (a.result == 0){
	    		      	$('#add_user_form').form('clear');  
	    		      	$('#dg').datagrid("reload") ;
	    		      }
	    		    }
    		   })
    	});
  		
		$('#add_user_form').keypress(function(event){
			if (event.keyCode!=13){
 				return;
			}
			saveUser();
		});
</script>
